<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>Admin</title>
        <link rel='stylesheet' href='../css/reset.css'/>
        <link rel='stylesheet' href='../css/960.css'/>
        <link rel='stylesheet' href='css/style.css'/>
        <script src="../Scripts/jquery-1.8.1.min.js" type="text/javascript"></script>
        
        <!-- Load TinyMCE -->
        <script type="text/javascript" src="tiny_mce/jquery.tinymce.js"></script>
        <script type="text/javascript">
                $().ready(function() {
                        $('.tinymce_editor').tinymce({
                                // Location of TinyMCE script
                                script_url : 'tiny_mce/tiny_mce.js',

                                // General options
                                theme : "advanced",
                                plugins : "autolink,lists,pagebreak,style,layer,table,save,advhr,advimage,advlink,emotions,iespell,inlinepopups,insertdatetime,preview,media,searchreplace,print,contextmenu,paste,directionality,fullscreen,noneditable,visualchars,nonbreaking,xhtmlxtras,template,advlist",

                                // Theme options
                                theme_advanced_buttons1 : "bold,italic,underline,strikethrough,|,justifyleft,justifycenter,justifyright,justifyfull,fontselect,fontsizeselect,|,insertfile,insertimage",
                                theme_advanced_buttons2 : "cut,copy,paste,pastetext,pasteword,|,bullist,numlist,|,outdent,indent,blockquote,|,undo,redo,|,link,unlink,anchor,image,cleanup,help,code",
                                theme_advanced_toolbar_location : "top",
                                theme_advanced_toolbar_align : "center",
                                theme_advanced_statusbar_location : "bottom",
                                theme_advanced_resizing : true,

                                // Replace values for the template plugin
                                template_replace_values : {
                                        username : "Some User",
                                        staffid : "991234"
                                }
                        });
                });
        </script>
        <!-- /TinyMCE -->
        <script>
            $(':button').click(function(){
                var file = $('#images').files[0];
                var name = file.name;
              $.ajax({
                        url: "processing/addNews.php",
                        type: "POST",
                        data: "filename=hoang",
                        success: function (res) {
                                $('#response').empty(); 
                                $('#response').html(res); 
                        }
                });
        </script>
        
    </head>
    <body>
        <div id ="container" class="container_12">
            
            <div id="banner" class="grid_12">
                    <img src='../img/logo.png'>
            </div><!--end banner wrap-->
            
            <div id="body" class="grid_12">
                <div id="siteBar" class="grid_4">
                    <?php
                        include 'siteBar.php';
                    ?>
                </div><!--end siteBar wrap -->
                <div id="main" class="grid_7">
                    <div class="section">
                        <h2>Tạo bài viết mới</h2>
                        <form method="post" enctype="multipart/form-data">
                            <ul>
                                <li class="listitem">
                                    <?php
                                        require "DB.php";
                                    ?>
                                    <div class="row">
                                        <label for="txtname">Tiêu đề:</label>
                                        <input class="textbox" id="txtten" name="name" type="text" value="" maxlength="255"/>
                                    </div>
                                    <div class="row">
                                        <label for="txtname">Mô tả:</label>
                                        <textarea class='textbox' id='txtmota' name='mota' rows='5' maxlength='255'></textarea>
                                    </div>
                                    <div class="row">
                                        <label for="txtname">Bài viết:</label>
                                    </div>
                                    <textarea id="txtcontent" name="baiviet" rows="20" cols="50" class="tinymce_editor"></textarea>
                                    <div class="row">
                                        <label for="txtname">Loại bài viết:</label>
                                        <select class="textbox" name="maloai">
                                             <?php
                                                $q = "SELECT * FROM NEWSTYPE";
                                                $r = mysql_query($q);
                                                while ($row = mysql_fetch_array($r))
                                                {                                               
                                                    $id = $row["ID"];
                                                    $type = $row["Type"];
                                                    echo "<option id='txtloai' value=$id> $type</option>";
                                                }
                                            ?>
                                        </select>
                                    </div>
                                    <div class="row">
                                        <label for="txtname">Thêm hình ảnh:</label>
                                        <input type="file" name="images" id="images" />
                                        <button type="submit" id="btn">Upload Files!</button>
                                        
                                    </div>
                                    <div class="row" id="response">
                                    </div>
                                    <script src="js/upload.js"></script>
                                </li>
                                
                                <li class="listitem">
                                    <div class="row rightalign">
                                        <input class="form-button" name="create" value="Tạo mới" type="button" />
                                    </div>
                                    <div id="warning"></div>
                                </li>    
                            </ul>    
                        </form>
                    </div>
                </div><!--end main wrap -->
                
            </div><!--end main wrap-->
            
            <div id="footer" class="grid_12">
            </div><!--end footer wrap-->
        </div><!--end container wrap-->
    </body>
</html>